//
//  TravelNotesParser.m
//  ITrip
//
//  Created by dlios on 15-5-22.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "TravelNotesParser.h"
#import "TravelNotesModel.h"
#import <AFNetworking.h>

@interface TravelNotesParser()


@end

@implementation TravelNotesParser


+ (NSMutableArray *)getParser:(NSData *)data
{
    NSMutableArray *arrayData = [NSMutableArray array];
    NSArray *array = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
    for (NSDictionary *dic in array) {
        TravelNotesModel *model = [TravelNotesModel getModel];
        model.name = [dic objectForKey:@"name"];
        if ([dic objectForKey:@"start_date"] != nil && ![[dic objectForKey:@"start_date"] isEqual:[NSNull null]] && [dic objectForKey:@"days"] != nil && ![[dic objectForKey:@"days"] isEqual:[NSNull null]] && [dic objectForKey:@"photos_count"] != nil && ![[dic objectForKey:@"photos_count"] isEqual:[NSNull null]]) {
            model.start_date = [dic objectForKey:@"start_date"];
            model.days = [[dic objectForKey:@"days"] integerValue];
            model.photos_count = [[dic objectForKey:@"photos_count"] integerValue];
        }
        model.front_cover_photo_url = [dic objectForKey:@"front_cover_photo_url"];
        
        model.image = [[dic objectForKey:@"user"] objectForKey:@"image"];
        model.id = [[dic objectForKey:@"id"] integerValue];
        [arrayData addObject:model];
    }
    return arrayData;
}



@end
